var tmx=null;
var tmy=null;


var path = 'localhost:8081/'; 
//"signCode_monitor_type_longtime"
var userCode = "lys_AAA"; 
var websocket; 
if ('WebSocket' in window) { 
  websocket = new WebSocket("ws://" + path + "wsz?userCode=" + userCode); 
} else if ('MozWebSocket' in window) { 
  websocket = new MozWebSocket("ws://" + path + "wsz?userCode=" + userCode); 
} else { 
  websocket = new SockJS("http://" + path + "wsz/sockjs?userCode=" + userCode); 
} 
websocket.onopen = function(event) { 
  console.log("WebSocket:已连接"); 
  console.log(event); 
}; 
websocket.onmessage = function(event) { 
  var data = JSON.parse(event.data); 
  var type=data.type;
  //console.log("WebSocket:收到一条消息-form", data); 
  if(type==1){
	  var tranAmont=data.data.transamont.amont;
	  var tranCount=data.data.transamont.count;
	  createJYInfoItem("#jye-detail", parseFloat(tranAmont).toFixed(2) );
	  createJYInfoItem("#jys-detail", parseFloat(tranCount).toFixed(0) );
	//  console.log("type:"+type+"||tranAmont:"+tranAmont+"||tranCount:"+tranCount); 
	  
  }else if(type==2){
	  var transOrders=data.data.transOrders;
	  addTransOrders(transOrders.sence,transOrders.channel,transOrders.orderNo,transOrders.amount);
  }else if(type==3){
	  var transRuntimeCount=data.data.transRuntimeCount;
	  tmx=transRuntimeCount.acqTime;
	  tmy=transRuntimeCount.transCount;
	  tmx = (new Date(tmx)).getTime();
	//  console.log(tmy,tmx);

  }
  
  //console.log("WebSocket:收到一条消息-form", data); 

}; 
websocket.onerror = function(event) { 
  console.log("WebSocket:发生错误 "); 
  console.log(event); 
}; 
websocket.onclose = function(event) { 
  console.log("WebSocket:已关闭"); 
  console.log(event); 
}


/* var x = (new Date()).getTime(), // 当前时间
y = Math.random() * 10; // 随机值 
series.addPoint([x, y], true, true);*/